/*
 * @Author: your name
 * @Date: 2021-06-02 10:20:22
 * @LastEditTime: 2021-06-02 10:59:25
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \遵义报名\zunyi\src\utils\localStorage.js
 */
// 获取localStorage
export const getStorage = (key) => {
    return localStorage.getItem(key) ? JSON.parse(localStorage.getItem(key)): null
}

// 设置localStorage
export const setStorage = (key, val) => {
    //是字符串就直接使用
    if (typeof val === "string") {
        localStorage.setItem(key, val)
    } else {//不是字符串就转字符串,存进去了再赚字符串
        localStorage.setItem(key, JSON.stringify(val))
    }
}

// 删除localStorage
export const removeStorage = (key) => {
    localStorage.removeItem(key)
}

// 清空localStorage
export const clearStorage = () => {
    localStorage.clear()
}